<%--这个是供号商,查看支付流水的jsp,引入到,spuser-splist里面作为弹窗出现--%>
<!-- Modal 查看账号流水-->
<%@ page language="java" contentType="text/html;charset=utf-8" %>
<!-- Modal 新增模态-->
<div class="modal fade" id="spuser_upload" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content" >
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                        aria-hidden="true">&times;</span></button>
                <h4 class="modal-title control-label" id="newWhiteIpsModallabel">上传二维码</h4>
            </div>
            <div style="padding: 0 20px;color: red;">
                注意事项：<br>
                1.上传的图片必须是<b style="color: rgb(0, 167, 239);">原图，原图，原图哦</b>
                （<u style="color: #1a2226">通过微信或者QQ转发的是缩略图</u>）<br>
                2.命名方法：<u style="color: #1a2226">任意金额码</u>
                须命名为<b style="color: rgb(0, 167, 239);">none.jpg</b><br>
                &emsp;&emsp;&emsp;&emsp;&emsp;&emsp;<u style="color: #1a2226">固定金额码</u>，比如100块钱的码，须命名为
                <b style="color: rgb(0, 167, 239);">100.jpg或者100.png</b>
            </div>
            <div class="modal-body" style="margin-top: 10px;">
                <div class="box-body " id="dvContent">
                    <form class="form-horizontal" action="/saveFile" method="POST" id="doc-vld-msg">
                        <input name="spId" value="" id="spId00" readonly="readonly" hidden>
                        <div class="form-group form-group-md">
                            <b>选择二维码图片</b>:<br>
                            <b style="color: red">*按住Ctrl或者Shift键，一次性可选择多张图片*</b>
                            <input type="file" name="files" id="imggu" multiple="multiple"
                                                class="form-control" />
                            <span id="guName" style="color: rgb(0, 167, 239);"></span>
                        </div>
                    </form>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal" id="cancel">放弃</button>
                <button type="button" class="btn btn-primary" id="addSpuserModalSureBtn">提交</button>
            </div>
        </div>
    </div>
</div>

<script>
    //监听返回name
    var $input = $("#imggu");
    var t_files;
    $input.on("change" , function(){
        t_files = this.files;
        var str = '';
        for (var i = 0, len = t_files.length; i < len; i++) {
            if(str !=''){
                str+="&nbsp;/&nbsp;"
            }
            str +=  t_files[i].name;
        };
        $('#guName').html(str);
    });
    $('#addSpuserModalSureBtn').click(function () {
        var spId = $('#spId00').val();
        if(typeof(t_files) =='undefined'){
            alert("请先选择图片");
            return;
        }
        var arrow = ".jpg.png";
        for (var i = 0, len = t_files.length; i < len; i++) {
            var fileName = t_files[0].name;
            var len1 = fileName.lastIndexOf(".");
            var ext = fileName.substr(len1, fileName.length - len1).toLowerCase();
            if (arrow.indexOf(ext) == -1) {
                alert("文件格式错误");
                return;
            }
        }
        //上传图片
        $.ajaxFileUpload({
            url: '${pageContext.request.contextPath}/ajax/jiexi?spId='+spId,
            secureuri: false,
            fileElementId: 'imggu', dataType: 'json',
            success: function (data) {
                if (data && data.code == "200") {
                    alert(data.message);
                    $('#cancel').click();
                    //把通道状态改一下
                    window.location.reload();
                }
                else {
                    alert("图片上传失败");
                }
            },error: function (data, status, e) {
                alert("error:" + data);
            }
        });
    });

</script>

